package com.kl.drs.task;
import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.kl.drs.common.BusinessKey;
import com.kl.drs.service.BankButtjointService;
import com.kl.drs.util.Log4jUtils;


/**
 * 对接银行job
 * @author WYN
 *
 */
@Component
@Configuration
@EnableScheduling
public class PSBCButtjointJob {
	@Autowired
	private BankButtjointService bankButtjointService;
	private static int THREAD_MAX_COUNT = 1;
	private static int currentCount = 0;
	private static int taskCount = 10;
	@Scheduled(cron= " 0 */5 * * * ? ")
	@Async
	public void excute(){
		Log4jUtils.logDebug("@Scheduled-------PSBCButtjointService.excute()---start:"+"\t\t" + new Date(System.currentTimeMillis()));
		if(currentCount<THREAD_MAX_COUNT){
			currentCount++;
			Log4jUtils.logDebug("PSBCButtjointService.excute()---business start:"+"\t\t" + new Date(System.currentTimeMillis()));
			//根据银行类型定时从服务器读取文件信息
				try {
					//bankButtjointService.buttjointICBCService(BusinessKey.BANK_BUTTJOINT_ICBC);
					bankButtjointService.buttjointPSBCService(BusinessKey.BANK_BUTTJIONT_PSBC);
				} catch (Exception e) {
					Log4jUtils.logError("PSBCButtjointService.excute()","@Scheduled-------PSBCButtjointService.excute(),错误："+e.getMessage(),e);
				}finally{
					currentCount--;
				}
			
				Log4jUtils.logDebug("PSBCButtjointService.excute()---business end:"+"\t\t" + new Date(System.currentTimeMillis()));
		}
		Log4jUtils.logDebug("@Scheduled-------PSBCButtjointService.excute()---end:"+"\t\t" + new Date(System.currentTimeMillis()));
	}
	}
